package com.PVZ.engine.factory;

import com.PVZ.engine.map.GameMap;
import com.PVZ.engine.map.MapBlock;
import com.PVZ.event.DeadEventListener;
import com.PVZ.model.emuns.MoveType;
import com.PVZ.model.emuns.PlantType;
import com.PVZ.model.plant.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by @Author: kabuda on @Date: 2021/5/24 19:41
 * <p>
 * 生成植物
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PlantFactory {
    private Point point;
    private List<Plant> allPlantsList = new ArrayList<>();

    public void generatePlant(PlantType plantType, int row, int col) {
        MapBlock[][] blockList = GameMap.blocks;


        Plant newPlant = null;

        switch (plantType) {
            case SunFlower: {
                newPlant = new SunFlower(row, col, MoveType.Stop);
                break;
            }
            case PeaShooterSingle: {
                newPlant = new PeaShooterSingle(row, col, MoveType.Stop);
                break;
            }
            case WallNut: {
                newPlant = new WallNut(row, col, MoveType.Stop);
                break;
            }
            case PeaShooter: {
                newPlant = new PeaShooter(row, col, MoveType.Stop);
                break;
            }
            case Caltrop: {
                newPlant = new Caltrop(row, col, MoveType.Stop);
                break;
            }
            case CherryBomb: {
                newPlant = new CherryBomb(row, col, MoveType.Stop);
                break;
            }
            case Tallnut: {
                newPlant = new Tallnut(row, col, MoveType.Stop);
                break;
            }
            case PotatoMine: {
                newPlant = new PotatoMine(row, col, MoveType.Stop);
                break;
            }
            case Pumpkin: {
                newPlant = new Pumpkin(row, col, MoveType.Stop);
                break;
            }
            default: {
                break;
            }
        }

        assert newPlant != null;
        //为植物绑定死亡事件
        // newPlant.bindListener(new DeadEventListener());
        this.allPlantsList.add(newPlant);
    }

}
